public class Defun extends Funcion {
	private Lisp lisp;

	/**
	 * Constructor
	 * @param lisp
	 */
	public Defun(Lisp lisp){
		setId("defun");
		setNumArg(0);
		this.lisp = lisp;
	}
	
	public Object funcion() {
		String res = "";
		setArg(getArg().replace("(", ","));
		String[] separado = getArg().split(",");
		setArg(getArg().replace(",", "("));
		String newArgs = "";
		for (int i = 2; i < separado.length; i++)
			newArgs += separado[i];
		newArgs = newArgs.substring(0, newArgs.length()-1);
		int numArgs = newArgs.replace("(", ",").split(",").length;
		String inst="";
		for(int i=2; i<separado.length; i++){
			inst += "(" + separado[i];
		}
		String id = separado[0].split(" ")[0];
		
		lisp.getFunc().put(id.hashCode(), new nuevaFuncion(lisp, id.toLowerCase(), inst, newArgs, numArgs));
		res = id + " ";
		return res;
	}

}
